﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace HZ.DrugTrade.Web.CommonPage
{
    public partial class GoodsInfo_GZHC : System.Web.UI.Page
    {
        string GoodsId = string.Empty;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["id"] != null)
            {
                GoodsId = HZ.Fun.CheckString(this.Request.QueryString["id"]);
                if (string.IsNullOrEmpty(GoodsId))
                {
                    Response.Write("参数错误！");
                    Response.End();
                }

                if (!HZ.Fun.IsInt(GoodsId))
                {
                    Response.Write("参数错误！");
                    Response.End();
                }
            }
            else
            {
                Response.Write("参数错误！");
                Response.End();
            }

            if (!IsPostBack)
            {
                BindData();
            }
        }
        protected void BindData()
        {
            int totalrecord = 0;
            var qm = new HZ.Data.QueryModel();

            //qm["GOODSIDNUM"] = GoodsId;
            qm["Append"] = "substr(GOODSIDNUM,0,14) =  '" + GoodsId.Substring(0,14) + "'";
            qm["SortFields"] = " ProductName ASC ";

            HZ.DrugTrade.Model.View.TB_Goods_GZHC Goods = HZ.DrugTrade.BLLFactory.Factory.BLL_Goods().GetGoodsByWhere_GZHC(qm, 1, 0, out totalrecord)[0];

            lblGoodsId.Text = Goods.GoodsId.ToString();//流水号
            lblSortName.Text = Goods.SortName.ToString();//类别名称
            lblProductCode.Text = Goods.ProductId.ToString();//目录编码
            lblProductName.Text = Goods.ProductName.ToString();//产品名称编号
            lblGoodsName.Text = Goods.CommonName.ToString();//通用叫法名称
            lblOneSortName.Text = Goods.OneSortName.ToString();//目录规格
            txtOutlookcmodel.Text = Goods.OutlookcModel.ToString();
            //if (!string.IsNullOrEmpty(Goods.SubmitTime.ToString())) { lblSubmitTime.Text = Goods.SubmitTime.Value.ToString("yyyy-MM-dd"); }
            lblCompanyName_Tb.Text = Goods.CompanyName_Tb.ToString();//投标（新增企业）
            lblCompanyName_SC.Text = Goods.CompanyName_Sc.ToString();//生产企业名称
            //最小包装
            lblMinPack.Text = Goods.MinPack;
            //全国最低中标价
            lblCountryMinimumPrice.Text = Goods.CountryMinimumPrice;
            //最低价中标地区
            if (Goods.MinimumArea != "" && Goods.MinimumArea != "无")
            {
                lblMinimumArea.Text = Goods.MinimumArea;
            }
            //全国最低供货价格
            lblCountryMinimumSupplyPrice.Text = Goods.CountryMinimumSupplyPrice;
            //最低价供货地区
            if (Goods.MinimumSupplyArea != "" && Goods.MinimumSupplyArea != "无")
            {
                lblMinimumSupplyArea.Text = HZ.DrugTrade.BLLFactory.Factory.BLL_Area().GetAreaName(Goods.MinimumSupplyArea);
            }
            //内蒙古最低价供货医疗机构
            //lblNMGMinimumSupplyPriceHosital.Text = Goods.NMGMinimumSupplyPriceHosital;
            //出厂价（到岸价）
            //lblFactoryPrice.Text = Goods.FACTORYPRICE;
            //单位
            lblGoodsUnit.Text = Goods.GOODSUNIT;
            //医疗器械注册证认可表或注册登记表  批准日期
            if (!string.IsNullOrEmpty(Goods.RegisterTime.ToString())) { lblRegisterTime.Text = Goods.RegisterTime.Value.ToString("yyyy-MM-dd"); }
            //产品标准 标准名称
            if (Goods.StandardName != null)
            {
                lblStandardName.Text = Goods.StandardName.ToString();
            }
            //海关报关单  报关单号
            if (Goods.CustomsId != null)
            {
                lblCustomsId.Text = Goods.CustomsId.ToString();
            }
            //判断如果该产品的投标人是代理企业则显示相应信息 add by xy20120914
            if (Goods.CompanyCode_Tb.Substring(0, 2) == "QJ")
            {
                IsShow.Visible = true;
                IsShwoOne.Visible = true;
                IsShows.Visible = true;
                //IsShow.Attributes.Add("style", "display:block;");
                //IsShwoOne.Attributes.Add("style", "display:block;");
                //IsShows.Attributes.Add("style", "display:block;");
                //国外生产企业的委托授权书或总代理证明  有效期
                if (!string.IsNullOrEmpty(Goods.GeneralManifestTime.ToString())) { lblGeneralManifestTime.Text = Goods.GeneralManifestTime.Value.ToString("yyyy-MM-dd"); }
                //国外生产企业名称  中文
                lblOverseasChineseName.Text = Goods.OverseasChineseName.ToString();

                //国外生产企业名称  英文
                lblOverseasEnglishName.Text = Goods.OverseasEnglishName.ToString();
            }
            else
            {
                IsShow.Visible = false;
                IsShwoOne.Visible = false;
                IsShows.Visible = false;
                //IsShow.Attributes.Add("style", "display:none;");
                //IsShwoOne.Attributes.Add("style", "display:none;");
                //IsShows.Attributes.Add("style", "display:none;");
            }
            //产品检测报告 检测单位
            lblTestingUnit.Text = Goods.TestingUnit;
            //产品检测报告 检测标准编号
            lblTestingId.Text = Goods.TestingId;
            lblRegCode.Text = Goods.RegCode.ToString();//注册证号
            if (!string.IsNullOrEmpty(Goods.RegDate.ToString())) { lblRegDate.Text = Goods.RegDate.Value.ToString("yyyy-MM-dd"); }
            lblRegName.Text = Goods.RegName.ToString();//注册证中文名称
            lblBrand.Text = Goods.Brand.ToString();//品牌
            lblRetailPrice.Text = Goods.RetailPrice.ToString();//零售价
            lblPerformance.Text = Goods.Performance.ToString();//性能描述及组成
            lblInstroduction.Text = Goods.Instroduction.ToString();//其他说明
            this.lblMinUnit.Text = Goods.MinUnit;

            #region add by xy
            if (Goods.GoodsName != null)
            {
                lblGoodsName.Text = Goods.GoodsName.ToString();
            }
            if (Goods.ProductMaterial != null)
            {
                lblProductMaterial.Text = Goods.ProductMaterial.ToString();
            }
            if (Goods.ProApplication != null)
            {
                lblProApplication.Text = Goods.ProApplication.ToString();
            }
            if (Goods.NMBottomPrice != null)
            {
                lblNMBottomPrice.Text = Goods.NMBottomPrice.ToString();
            }
            lblCOMPANYADDRESS_SC.Text = Goods.COMPANYADDRESS_SC;
            lblQuality1.Text = Goods.QualityLevels == "" ? "" : Goods.QualityLevels;
            #endregion
            //2014年
            if (!string.IsNullOrEmpty(Goods.HealthMinistrySituation))
            {
                lblHealthMinistrySituation.Text = Goods.HealthMinistrySituation;//原卫生部中标情况
                if (Goods.HealthMinistrySituation == "中标")
                {
                    IsPrice.Visible = true;
                }
                else
                {
                    IsPrice.Visible = false;
                }
            }
            else
            {
                IsPrice.Visible = false;
            }
            txtHealthMinistryPrice.Text = Goods.HealthMinistryPrice.ToString();//原卫生部中标价格
            txtRegisterCompanyName.Text = Goods.RegisterCompanyName;//生产者名称
            txtImportRegister_Agent.Text = Goods.ImportRegister_Agent;//进口产品注册代理
            txtImportCustomerService.Text = Goods.ImportCustomerService;//进口产品售后服务机构
            txtNote.Text = Goods.Note.ToString();//注册证登记表备注
            if (!string.IsNullOrEmpty(Goods.IsOutsourcing))
            {
                lblIsOutsourcing.Text = Goods.IsOutsourcing;//有无外购件
            }
            if (!string.IsNullOrEmpty(Goods.IsQualificationQualified))
            {
                lblIsQualificationQualified.Text = Goods.IsQualificationQualified;//相关资质证明材料是否合格
            }
            if (!string.IsNullOrEmpty(Goods.IsSpecialProve))
            {
                lblIsSpecialProve.Text = Goods.IsSpecialProve;//国家有特殊强制性规定的产品相应证书或证明材料
            }
            if (!string.IsNullOrEmpty(Goods.IsMedicalInstruments))
            {
                lblIsMedicalInstruments.Text = Goods.IsMedicalInstruments;//医疗器械质量管理体系证书
            }
            if (!string.IsNullOrEmpty(Goods.IsInstructions))
            {
                lblIsInstructions.Text = Goods.IsInstructions;//产品说明书
            }
            if (!string.IsNullOrEmpty(Goods.IsEntityImg))
            {
                lblIsEntityImg.Text = Goods.IsEntityImg;//实物图片
            }
            if (!string.IsNullOrEmpty(Goods.ImportEnterCheckout))
            {
                lblImportEnterCheckout.Text = Goods.ImportEnterCheckout;//进口产品入境货物检验检疫证明
            }
            if (!string.IsNullOrEmpty(Goods.IsCustoms))
            {
                lblIsCustoms.Text = Goods.IsCustoms;
                if (Goods.IsCustoms == "有")
                {
                    IsCustoms.Visible = true;
                }
                else
                {
                    IsCustoms.Visible = false;
                }
            }
            else
            {
                IsCustoms.Visible = false;
            }

            //if (!string.IsNullOrEmpty(Goods.EntityImg))
            //{
            //    string[] pic = Goods.EntityImg.Split('|');
            //    for (int i = 0; i < pic.Length; i++)
            //    {
            //        if (!string.IsNullOrEmpty(pic[i].ToString()))
            //        {
            //            switch (i)
            //            {
            //                case 0:
            //                    OnePic.InnerHtml = "<img  src=\"../upload/" + pic[i].ToString() + "\" width=\"150px\"  height=\"120px\"  onclick=\"ShowPic('" + pic[i].ToString() + "')\" title=\"" + pic[i].ToString() + "\" />";
            //                    break;
            //                case 1:
            //                    Div2.InnerHtml = "<img  src=\"../upload/" + pic[i].ToString() + "\" width=\"150px\"  height=\"120px\"  onclick=\"ShowPic('" + pic[i].ToString() + "')\" title=\"" + pic[i].ToString() + "\" />";
            //                    break;
            //                case 2:
            //                    Div3.InnerHtml = "<img   src=\"../upload/" + pic[i].ToString() + "\" width=\"150px\"  height=\"120px\"  onclick=\"ShowPic('" + pic[i].ToString() + "')\" title=\"" + pic[i].ToString() + "\" />";
            //                    break;
            //            }
            //        }
            //    }
            //}

            if (!string.IsNullOrEmpty(Goods.InstructionsImg))
            {
                string[] pic = Goods.InstructionsImg.Split('|');
                for (int i = 0; i < pic.Length; i++)
                {
                    if (!string.IsNullOrEmpty(pic[i].ToString()))
                    {
                        switch (i)
                        {
                            case 0:
                                PackImgDv.InnerHtml = "<img  src=\"../upload_one/" + pic[i].ToString() + "\" width=\"150px\"  height=\"120px\"  onclick=\"ShowPic('" + pic[i].ToString() + "')\" title=\"" + pic[i].ToString() + "\" />";
                                break;
                            case 1:
                                TwoPic.InnerHtml = "<img  src=\"../upload_one/" + pic[i].ToString() + "\" width=\"150px\"  height=\"120px\"  onclick=\"ShowPic('" + pic[i].ToString() + "')\" title=\"" + pic[i].ToString() + "\" />";
                                break;
                            case 2:
                                ThreePic.InnerHtml = "<img   src=\"../upload_one/" + pic[i].ToString() + "\" width=\"150px\"  height=\"120px\"  onclick=\"ShowPic('" + pic[i].ToString() + "')\" title=\"" + pic[i].ToString() + "\" />";
                                break;
                        }
                    }
                }
            }

            if (!string.IsNullOrEmpty(Goods.OuterPack_Img))
            {
                string[] pic = Goods.OuterPack_Img.Split('|');
                for (int i = 0; i < pic.Length; i++)
                {
                    if (!string.IsNullOrEmpty(pic[i].ToString()))
                    {
                        switch (i)
                        {
                            case 0:
                                PackImgOut.InnerHtml = "<img  src=\"../upload_pack/" + pic[i].ToString() + "\" width=\"150px\"  height=\"120px\"  onclick=\"ShowOutPic('" + pic[i].ToString() + "')\" title=\"" + pic[i].ToString() + "\" />";
                                break;
                        }
                    }
                }
            }
        }
    }
}